Copying and Comparing: Problems and Solutions

نویسندگان

  • Peter Grogono
  • Markku Sakkinen
چکیده

In object oriented programming, it is sometimes necessary to copy objects and to compare them for equality or inequality. We discuss some of the issues involved in copying and comparing objects and we address the problem of generating appropriate copying and comparing operations automatically, a service that is not provided by most object oriented languages and environments. Automatic generation appears to be not only desirable, because hand-coding these methods is mechanical and yet error-prone, but also feasible, because the form of the code is simple and largely predictable. Some languages and some object models presented in the literature do support generic copying and comparing, typically defining separate “shallow” and “deep” versions of both operations. A close examination of these definitions reveals inadequacies. If the objects involved are simple, copying and comparing them is straightforward. However, there are at least three areas in which insufficient attention has been given to copying and comparing complex objects: (1) values are not distinguished from objects; (2) aggregation is not distinguished from association; and (3) the correct handling of linked structures other than trees is neglected. Solving the third problem requires a mechanism built into the language, such as exists in Eiffel. Building such a mechanism without modifying the language requires a language with sufficient reflexive facilities, such as Smalltalk. Even then, the task is difficult and the result is likely to be insecure. We show that fully automatic generation of copying and comparing operations is not feasible because compilers and other software tools have access only to the structure of the objects and not to their semantics. Nevertheless, it is possible to provide default methods that do most of the work correctly and can be fine-tuned with a small additional amount of hand-coding. We include an example that illustrates the application of our proposals to C++. It is based on additional declarations handled by a preprocessor.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Term Graphs and Principal Types for X

In this paper we study the calculus of circuits X , as first presented in [13] and studied in detail in [5]. We will present a number of new implementations of X using term graph rewriting techniques, which are improvements of the technique used in [6]. We will show that alpha conversion can be dealt with ‘on the fly’, and that explicit copying can be avoided, by presenting, discussing and comp...

متن کامل

Code-Copying in the Balochi Language of Sistan

This empirical study deals with language contact phenomena in Sistan. Code-copying is viewed as a strategy of linguistic behavior when a dominated language acquires new elements in lexicon, phonology, morphology, syntax, pragmatic organization, etc., which can be interpreted as copies of a dominating language. In this framework Persian is regarded as the model code which provides elements for b...

متن کامل

THE IMPACT OF TEACHING SUMMARIZING ON EFL LEARNERS’ MICROGENETIC DEVELOPMENT OF SUMMARY WRITING

Summary writing is associated with lots of cognitive and metacognitive complexities that necessitates instruction (Hirvela & Du, 2013). Contrary to majority of studies carried out on summarization instruction, the present study addressed the underlying processes or microgenetic developments of the Iranian EFL learners’ summary writing. To this end, 41 male and female undergraduate students rece...

متن کامل

Copying and Comparing : Problems

In object oriented programming, it is sometimes necessary to copy objects and to compare them for equality or inequality. We discuss some of the issues involved in copying and comparing objects and we address the problem of generating appropriate copying and comparing operations automatically, a service that is not provided by most object oriented languages and environments. Automatic generatio...

متن کامل

Application of the tan(phi/2)-expansion method for solving some partial differential equations

In this paper, the improved  -expansion method is proposed to solve the Kundu–Eckhaus equation and Gerdjikov–Ivanov model. The applied method are analytical methods to obtaining the exact solutions of nonlinear equations. Here, the aforementioned methods are used for constructing the soliton, periodic, rational, singular and solitary wave solutions for solving some equations. We obtained furthe...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2000